<?php
error_reporting(E_ALL ^ E_NOTICE);

set_time_limit(0);
$db1=mysql_connect("localhost","root","root"); 
mysql_select_db('faithwar',$db1); 

$db2=mysql_connect('192.168.1.246','root','root'); 
mysql_select_db('faithwar',$db2); 

date_default_timezone_set("PRC"); //timezone
#$dateTime = date("Y-m-d",strtotime("-1 day"));
$dateTime = date("Y-m-d");

    $deviceid_query = mysql_query("select DISTINCT deviceid,firstlogin from  faithwar_sevenday",$db2); //id


while($deviceid = mysql_fetch_array($deviceid_query))
{
  $sql = "UPDATE  deviceid SET date= '$deviceid[firstlogin]' WHERE deviceid= '$deviceid[deviceid]'";
   if(mysql_query($sql,$db1)){
    echo "1 update is ok!";
} else {
    echo "failed".mysql_error();
}

}

mysql_close($db1);
mysql_close($db2);
?>